I tried Reducing Lambda cost by using lambda power tuning
How Lambda pricing works
https://aws.amazon.com/lambda/pricing/
- It charges us based on the amount of memory allocated to the function
we can save money by allocating appropriate memory
- how long the function runs by the millisecond
-
also charges the fixed price of 0.20$ per million requests (or invocation)
Extra cost: Data transfer cost
Lambda@Edge Pricing
When to optimize Lambda functions for cost?
- we should always optimize lambda functions that use provision concurrency
1 provisioned concurrency with 128mb memory = 1.40$ per month
1 provisioned concurrency with 10GB memory = 111.16$ per month
- a function that invokes millions of times with a long execution time
we can save money by allocating more memory if a task needs more CPU cycle
task can be cheaper if choosing more memory for a short amount of time as compared to running for a longer amount of time with less memory
Lambda power tuning- help to find the best memory Setting for your app
this will help you to choose the right size of memory based on performance, cost or a combination of both
I tried
I already created a temp lambda function for testing
- open the above link and click on deploy >
check on I acknowledge that this app creates custom IAM roles. > deploy
- after Deployment is successfully completed -> State Function State Machine -> click on power tuning State machine
- click on Execute
paste the json payload with your lambda function ARN and strategy
{ "lambdaARN": "your-lambda-function-arn", "powerValues": [128, 256, 512, 1024, 2048, 3008], "num": 10, "payload": "{}", "parallelInvocation": true, "strategy": "cost" }
- after Execution you can check the output and recommended memory Setting for your strategy
- we can also see the visualization by opening link available in output
reason for not always using lambda-power-tuning :
- Capture and maintain payload for Each function
- plan and execute function for each function
- cost of running power tuning State machine
- Repeat every time the function Changes
- Require time
Picking the right functions to power tuning
We should sort all our function and choose the function which are costing more and power tune them
Other ways to save money
Using ARM architecture
graviton is 25% Cheaper than x86
can be considered if your application is not required intensive io
Using provisioned concurrency
provisioned concurrency is 70 % cheaper as compare to On Demand
References:
https://serverlessrepo.aws.amazon.com/applications/arn:aws:serverlessrepo:us-east-1:451282441545:applications~aws-lambda-power-tuning
Conclusion:
Hope you can save few bugs using above Information
Thank you,